package com.m3958.firstgwt.server.servlet;

import java.io.IOException;

import javax.persistence.EntityManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.util.EntityUtils;

import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import com.m3958.firstgwt.server.service.HttpClientService;


@Singleton
public class SolrSearchServlet extends HttpServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Inject
	private Injector injector;
	
	@Inject
	HttpClientService httpclientService;
	
	@Inject
	protected com.google.inject.Provider<EntityManager> emp;
	/*
	 * 查找，bytitle，bycontent，bytag，bysection，obname
	 * 参数：searchfor
	 */
	
	@Override
	public void doGet(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		
        HttpGet httpget = new HttpGet("http://search.m3958.com/solr-numberone/select?q=abc");
        
        HttpResponse response = httpclientService.getHttpClient().execute(httpget,new BasicHttpContext());
        
        HttpEntity entity = response.getEntity();
        System.out.println(response.getStatusLine());

        System.out.print(EntityUtils.toString(entity));
	}
}
